from mylist import MyList


class MyListSub(MyList):
    calls = 0

    def __init__(self, data) -> None:
        super().__init__(data)
        self.adds = 0

    def __add__(self, other):
        print('add: ', str(other))
        MyListSub.calls += 1
        self.adds += 1
        return super().__add__(other)

    def stats(self):
        return MyListSub.calls, self.adds

if __name__ == '__main__': 
  x = MyListSub('spam') 
  y = MyListSub('foo') 
  print(x[2]) 
  print(x[1:]) 
  print(x + ['eggs']) 
  print(x + ['toast']) 
  print(y + ['bar']) 
  print(x.stats())